#ifndef _MULT_PACK_
#define _MULT_PACK_

#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
#include "../DF_Common/com_sparse_row.h"
#include "../DF_Common/basis_state.h"
#include "../DF_Common/coupling_coeff.h"
#include "../DF_Common/progress_bar.h"
#include "../DF_Common/const_nucl.h"
//#include "package.h"
//#include "serial_control.h"
// #include "antisym_coeff.h"
//
// #include "cont_term.h"
//
// #include "ope_term.h"
//
// #include "tpe_term.h"
// #include "trans_coeff.h"
//

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
namespace bf = boost::filesystem;

class Multi_Pack {
public:
  double LEC_C1;
  double LEC_C3;
  double LEC_C4;
  double LEC_CD;
  double LEC_CE;
  double LEC_gA;
  double hbar_omega;
  int regulator_pow;
  int Cut_Lambda;
  int E_max;
  int flag_const = 1;

  SMatrix_Ch vec_S, vec_Tz_S;
  SMatrix_Ch vec_flag_S, vec_flag_Tz_S; // sparse matrix for vec
  SMatrix_Ch vec_A_S, vec_B_S, vec_flag_A_S, vec_flag_B_S;
  vector<vector<vector<double>>> vec;
  vector<vector<vector<int>>> vec_flag;
  // vector<vector<vector<double>>> vec_A, vec_B, vec; // vec_Tz; //
  // vec[TP_channel][i][j] vector<vector<vector<int>>> vec_flag_A, vec_flag_B,
  //     vec_flag;                           // vec_flag_Tz;
  vector<int> ch_2A, ch_2B;               // channel index to A & B
  vector<vector<int>> index_2A, index_2B; // index to A & B

  TripleP TP_A, TP_B, TP;
  SingleP SP_A, SP_B, SP;
  //int Hbar_Omega;
  double EPS = 0.0000001;
  int _A;
  Multi_Pack() : _A(0){};
  // Multi_Pack(string file_sub1, string file_sub2);
  void init_sub(string file, SMatrix_Ch &vec_t, SMatrix_Ch &vec_flag_t,
                TripleP &triple_t, SingleP &single_t);
  void init(string file_sub1, string file_sub2);

  int compare_sp(SingleP &sp_A, SingleP &sp_B);
  void compare_tp(TripleP &tp_T, TripleP &tp_x, vector<int> &ch_2x,
                  vector<vector<int>> &index_2x);
  void build();
  void build_S();
  void print(std::string filename);
  void print_Tz(std::string filename);

  void print_2AB(std::string filename1, std::string filename2);
  void check(std::string filename);
};
#endif
